const obj = {
    name: 'xxx',
    obj: {
        age: 18
    }
}
const arr = [1, 2, 3, 4, [5]]

const data = Object.freeze(obj)
const data1 = Object.freeze(arr)
data.name = 'xxxxxx'
data1[0] = 11111
/**
 * 改变无效，结果为xxx 和 1
*/
console.log(data.name)
console.log(data1[0])


data.obj.age = 20
data1[data1.length - 1][0] = 5555
/**
 * 改变有效，结果为20  和 5555
*/
console.log(data.obj.age)
console.log(data1[data1.length - 1][0])


/**
 * 深度冻结
*/
const deepFreeze = (data) => {
    for (let key in data) {
        if (data[key] !== null && typeof data[key] === 'object') {
            deepFreeze(data[key])
        }
    }
    return Object.freeze(data)
}
